package io.renren.controller;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.mapper.EntityWrapper;

import io.renren.common.utils.R;
import io.renren.entity.CCSChannelEntity;
import io.renren.response.CCSChannelResponse;
import io.renren.service.CCSChannelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 选题栏目接口
 * @author SongR
 *
 */
@RestController
@RequestMapping("/api")
@Api(tags = "选题栏目接口")
public class ApiChannelController {

	@Autowired
	CCSChannelService cService;	
	/**
	 * 获取栏目
	 * @return
	 */
	@GetMapping("getChannel")
	@ApiOperation(value = "获取选题栏目",notes="用于选题添加", response = CCSChannelResponse.class)
	public R getChannel(){
		List<CCSChannelEntity> channles = cService.selectList(new EntityWrapper<CCSChannelEntity>().eq("channel_status", 1));
		List<CCSChannelResponse> cr = new ArrayList<CCSChannelResponse>();
		for (CCSChannelEntity c : channles) {
			CCSChannelResponse channel = new CCSChannelResponse();
			BeanUtils.copyProperties(c, channel);
			cr.add(channel);
		}
		return R.ok().put("result", cr);
	}
	
	
	
}
